package events
{
	import flash.events.Event;
	import model.micro.Battle;
	
	/**
	 */
	public class BattleEvent extends Event
	{
		/**
		 * Occurs when a projectile is created in a battle.
		 */
		public static const PROJECTILE_CREATED:String = "projectileCreated";
		/**
		 * Occurs when a unit is deployed from the garrison.
		 */
		public static const GARRISON_DEPLOYED:String = "garrisonDeployed";
		/**
		 * Occurs when a field unit enters the garrison.
		 */
		public static const UNIT_GARRISONED:String = "unitGarrisoned";
		/**
		 * Occurs when a unit dies.
		 */
		public static const UNIT_KILLED:String = "unitKilled";
		/**
		 * Occurs when a unit is selected.
		 */
		public static const UNIT_SELECTED:String = "unitSelected";
		/**
		 * Occurs when the battle is over.
		 */
		public static const BATTLE_ENDED:String = "battleEnded";
		
		/**The battle this event was created by.*/
		private var _battle:Battle;
		private var _data:Object;
		
		public function BattleEvent(type:String, battle:Battle, data:Object = null)
		{
			super(type, true);
			_battle = battle;
			_data = data;
		}
		
		/**
		 * The battle this event was created by.
		 */
		public function get battle():Battle
		{
			return _battle;
		}
		
		public function get data():Object
		{
			return _data;
		}
		
		override public function toString():String
		{
			return "[BattleEvent type='" + type+ "]";
		}
		
		override public function clone():Event 
		{
			return new BattleEvent(type, battle, data);
		}
	}
}